package com.sanjin.form;

import com.sanjin.form.interfaces.Create;
import com.sanjin.form.interfaces.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

/**
 * @description:
 * @author: sanjin
 * @date: 2019/5/7 20:00
 */
@Data
@ApiModel
public class AdminForm {

    @ApiModelProperty(value = "id，update必须传递，create不允许传递")
    @NotNull(groups = Update.class, message = "update 必须包含id")
    @Null(groups = Create.class, message = "create 不允许包含id")
    private Integer id;

    @ApiModelProperty(value = "username")
    @NotNull(message = "username must not be null.")
    @Length(min = 5, max = 32)
    private String username;

    @ApiModelProperty(value = "password,创建需要，修改不需要")
    @Null(groups = Update.class, message = "password must not be null when update")
    @NotNull(groups = Create.class, message = "password must be not null when create")
    @Length(min = 10, max = 32)
    private String password;

    @ApiModelProperty(value = "role 角色")
    @NotNull(groups = Update.class,message = "role must not be null when update")
    @Null(groups = Create.class, message = "role must be null when create.")
    private String role;
}
